package com.maiji.cloud.entities.shopingmall;

import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.Version;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@NoArgsConstructor
@Data
@Accessors(chain = true)
@Table(name = "discount_coupon")
public class DiscountCoupon {

	@TableId
	@Column(name = "uu_id", type = MySqlTypeConstant.VARCHAR, length = 50, isKey = true)
	private String uuId;

	@Column(name = "face_value", type = MySqlTypeConstant.INT, length = 50)
	private Integer faceValue; // 面值

	@Column(name = "money", type = MySqlTypeConstant.INT, length = 50)
	private Integer money; // 满多少可用

	@Column(name = "integral", type = MySqlTypeConstant.INT, length = 50)
	private Integer integral; // 积分

	@Column(name = "amount", type = MySqlTypeConstant.INT, length = 50, defaultValue = "0")
	private Integer amount; // 优惠券数量

	@Column(name = "in_time", type = MySqlTypeConstant.DATETIME)
	private Date inTime;
	
	@Column(name = "start_time", type = MySqlTypeConstant.DATETIME)
	private Date startTime;//优惠券有效期开始时间
	
	@Column(name = "end_time", type = MySqlTypeConstant.DATETIME)
	private Date endTime;//优惠券有效期结束时间
	
	@Column(name = "type", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
	private Integer type;// 1:积分兑换，2：免费领取

	@Column(name = "unit", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
	private Integer unit;// 1:年，2：月，3：日
	
	@Column(name = "num", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
	private Integer num;//领取之后几个年，几个月，几个年优惠券失效

	@Version
	@Column(name = "version", type = MySqlTypeConstant.INT, length = 1, defaultValue = "0")
	private Integer version; // 数据版本号

    @TableField(exist = false)
    private String realmName;

    @TableField(exist = false)
    private String url = "/pages/shop/coupon?discountCouponId=";

    public String getUrl() {
        return this.realmName + this.url + this.uuId;
    }

}
